#include "StdAfx.h"
#include "Parameter.h"

#include "ConfigFile.h"
//#include "OptDlg.h"
//#include "PicOptDlg.h"

Parameter::Parameter(void)
{
//	mconfigfile = new ConfigFile(); hs_add("configfile", mconfigfile);	TRACE(_T("=== configfile new: 0x%x\n"), mconfigfile);
//	mpicoptdlg = new PicOptDlg();	hs_add("picoptdlg", mpicoptdlg);	TRACE(_T("=== picoptdlg new: 0x%x\n"), mpicoptdlg);
//	moptdlg = new OptDlg();			hs_add("optdlg", moptdlg);			TRACE(_T("=== optdlg new: 0x%x\n"), moptdlg);
//	moptdlg->Create(IDD_DIALOG_OPTION);
}
Parameter::~Parameter(void)
{
//	if ( mconfigfile)	{		delete mconfigfile; mconfigfile = NULL;	}
//	if (mpicoptdlg)		{		delete mpicoptdlg;	mpicoptdlg = NULL;	}
//	if (moptdlg)		{		delete moptdlg ;	moptdlg = NULL;	}
}
int Parameter::init()
{
//	mconfigfile->init();
//	moptdlg->init();
//	return load();
	return 0;
}
int Parameter::load()
{
	ConfigFile *cf = mconfigfile;
	TRACE(_T("---- >>> parameter.load: enter\n" ));
	if ( !cf->isEixst())
	{
		TRACE(_T("-----!!!!!!prm.load: configfile is not exist;\n"));
		return 1;
	}

	int d;
	CString s;
	CString sec = _T("common");
	s = cf->GetStr(sec,(CString)TEXT("dcdir"));	//gprms->dcdir = s; //(s);//gIDaqSaver->setSaveDir( s );
		
	sec = TEXT("daq");
	s = cf->GetStr(sec,(CString)TEXT("datdir"));//gprms->datdir = s;//	dqf_setDataDir(s);//gIFileDaqer->setDataDir(s );
	s = cf->GetStr(sec,(CString)TEXT("mvdir"));	//gprms->mvdir = s; //(s);//gIFileDaqer->setMoveDir(s);
	d = cf->GetInt(sec,TEXT("source"),-1);		//gprms->daqsource = d; //(d);//gIDaqThread->setSource(d);
	d = cf->GetInt(sec,TEXT("fetchlen"),-1);	//gprms->fetchlen = d;//	dqt_setFetchlen(d);//gIDaqThread->setFetchlen(d);
	d = cf->GetInt(sec,TEXT("save"),-1);		//gctls->issave = d;//	dqt_setSave(d);//gIDaqThread->setSave( d );
	d = cf->GetInt(sec,TEXT("bufnum"),-1);		//gprms->daqbufnum = d; //(d);//gIDaqBuffer->setBufnum(d);
	d = cf->GetInt(sec,TEXT("usernum"),-1);		//gprms->daqbufusernum =d;//gIDaqBuffer->setUsernum(d);

	
	sec = TEXT("dc");

	d = cf->GetInt(sec, TEXT("save"), -1);		//gctls->issavedcsrc = d;
	d = cf->GetInt(sec, TEXT("savefd"), -1);	//gctls->issavefd = d;
	d = cf->GetInt(sec, TEXT("saveccdfd"), -1);	//gctls->issaveccdfd = d;
	d = cf->GetInt(sec, TEXT("shownum"), -1);	//gprms->shownum = d;
	d = cf->GetInt(sec, TEXT("showway"), -1);	//gprms->showway = d;
	d = cf->GetInt(sec, TEXT("gain"), -1);		//gman->SetGain(d);
	
	TRACE(_T("---- >>> prm.load: exit\n" ));
}
int Parameter::save()
{
	return 1;
}
int Parameter::sync( bool b )
{
	return 1;
}
void Parameter::show( void)
{
//	moptdlg->ShowWindow( SW_SHOW);
//	moptdlg->DoModal();
}